package com.cloud.bio;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class BIOServiceWithPool {
    public static void main(String[] args) throws IOException {
        ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
        ServerSocket serverSocket = new ServerSocket(12345);
        System.out.println("伪异步IO服务器启动----------");
        while (true){
            final Socket socket = serverSocket.accept();
            System.out.println("有一个新连接--------------");
            newCachedThreadPool.execute(() -> BIOService.handler(socket));
        }
    }
}
